<template>
    <!-- 大量节点性能测试 -->
    <div class="canvas-wrap">
        <canvas id="myCanvas" width="1780" height="1080" style="border: 0px solid"></canvas>
    </div>
</template>
    
<script lang="ts">
import GridSystem from "../GridSystem";
import Pnt from "@/features/function-shape/Pnt";
import { Utils } from "@/utils";
import Rect from "@/features/basic-shape/Rect";

export default {
    data() {
        return {
        };
    },
    mounted() {
        let canvas = document.querySelector("#myCanvas") as HTMLCanvasElement;

        let gls = new GridSystem(canvas);
        gls.extent = [750, 800, 750, 800]

        function startTime() {
            gls.draw(true, () => {
            });
        }
        startTime();

        for (let index = 0; index <= 3000; index++) {
            let rect = new Rect(gls.getRelativeLen(Utils.randomNum(0, gls.ctx.canvas.width)) * 2, gls.getRelativeLen(Utils.randomNum(0, gls.ctx.canvas.height)) * 2, 20, 20)   // 5个单位长度
            // let rect = new Pnt(gls.getRelativeLen(Utils.randomNum(0, gls.ctx.canvas.width)) * 2, gls.getRelativeLen(Utils.randomNum(0, gls.ctx.canvas.height)) * 2, 1,1)   // 5个单位长度
            gls.addFeature(rect);
        }
    },
};
</script>

<style>
body {
    margin: 0;
}

button {
    margin: 5px;
}

canvas {
    /* background-color: #000; */
}
</style>